var One=function(){
    this.表现进化力=90;
    this.本能进化力=90;
    this.探索=30;
    this.认同=30;
    this.对比=30;
    this.pos={x:0,y:1,z:0};//xz表示平面社交网络，y表示社交地位
    this.inner={};//加和为进化力
    this.outer={};//考虑周围环境进行分配，还是初始与inner相同？
    this.radius=1;
    this.view=50;//视野
    this.sensitivity=5;//敏感度
    this.id=null;
    this.antieducation=70;//抗教化能力
    this.arr_history=[];
}
//在平面社交网络中建立多个One，注意他们不能重叠
//参数：保存One的数组，建立个数，x方向范围【】，z方向范围【】
One.createRandomThem=function(obj_them,count,arr_x,arr_z){
    for(var i=0;i<count;i++)
    {
        var one=new One();
        one.id="One_"+i;
        var inner={};
        var sum_inner=0;
        for(var key in dic.justice)
        {
            inner[key]=Math.random();//权重
            sum_inner+=inner[key];

        }
        var rate=one.本能进化力/sum_inner;
        for(var key in inner)
        {
            one.inner[key]=inner[key]*rate;
            one.outer[key]=one.inner[key];
        }
        One.setPos(obj_them,one,arr_x,arr_z);
        var obj0=one;
        var obj={};
        obj.表现进化力=obj0.表现进化力;
        obj.本能进化力=obj0.本能进化力;
        obj.探索=obj0.探索;
        obj.认同=obj0.认同;
        obj.对比=obj0.对比;
        obj.pos=obj0.pos;
        obj.inner=obj0.inner;
        obj.outer=obj0.outer;
        obj.radius=obj0.radius;
        obj.view=obj0.view;
        obj.antieducation=obj0.antieducation;
        obj.sensitivity=obj0.sensitivity;
        obj.lover=obj0.lover;
        obj.influence=obj0.influence;
        one.arr_history.push(obj);//记录单位的最初状态


        obj_them[one.id]=one;
    }
    return obj_them;//既改变又返回

}
One.setPos=function(obj_them,one,arr_x,arr_z)
{
    one.pos.x=newland.RandomBetween(arr_x[0],arr_x[1]);
    one.pos.z=newland.RandomBetween(arr_z[0],arr_z[1]);
    for(var key in obj_them)
    {
        var olderOne=obj_them[key];
        if(vxz.distance(olderOne.pos,one.pos)<(olderOne.radius+one.radius))//如果太近
        {
            One.setPos(obj_them,one,arr_x,arr_z);//第一次未失败的递归会设定pos
            break;
        }
    }
    return one;
}
//把单位对象集群转化为易于传输的格式，主要是剔除了网格信息
One.obj2data=function(obj_them){
    var obj_send={};
    for(var key in obj_them)
    {
        var one=obj_them[key];
        var obj_p={
            本能进化力:one.本能进化力,
            表现进化力:one.表现进化力,
            探索:one.探索,
            认同:one.认同,
            对比:one.对比,
            pos:one.pos,
            inner:one.inner,
            outer:one.outer,
            radius:one.radius,
            view:one.view,
            sensitivity:one.sensitivity,
            antieducation:one.antieducation,
            id:one.id,
        }
        obj_send[key]=obj_p;
    }
    return obj_send;
}